package tds.model1.version2;

/**
 * 
 * @Company 杭州先锋电子技术股份有限公司
 * @ClassName CalculateFactory
 * @Description TODO(简单工厂模式获取需要的计算类)
 * @author tds
 * @Date 2019年1月3日 下午2:59:57
 * @version 1.0.0
 */
public class CalculateFactory {
	public static Calculate getCalculate(String operator){
		Operate operate = Operate.valueOperationOf(operator);
		if(operate == null){
			throw new RuntimeException("操作符不存在");
		}
		Calculate result = null;
		switch (operate) {
			case ADD:
				result = new AddCalculate();
				break;
			case SUB:
				result = new SubCalculate();
				break;
			case MUL:
				result = new MulCalculate();
				break;
			case DIV:
				result = new DivCalculate();
				break;
	
			default:
				result = null;
				throw new RuntimeException("未知的操作符");
		}
		return result;
	}
}
